package com.qsmx.store.app.http;

import android.content.Context;

import com.alibaba.fastjson.JSONObject;
import com.qsmx.store.app.fustion.FustionManager;
import com.qsmx.store.app.util.StringUtil;
import com.qsmx.store.core.net.RestClient;
import com.qsmx.store.core.net.callback.IError;
import com.qsmx.store.core.net.callback.IFailure;
import com.qsmx.store.core.net.callback.ISuccess;
import com.qsmx.store.core.util.log.AtmosLogger;

import java.util.WeakHashMap;

public class HttpHelper {

    public static void RestClientPost(WeakHashMap<String, Object> param, String url, ISuccess success, IError error, IFailure failure) {
        AtmosLogger.e("url", url);
        RestClient
                .builder()
                .token(FustionManager.mLoginData.getToken())
                .url(url)
                .params(param)
                .success(success)
                .failure(failure)
                .error(error)
                .build()
                .post();
    }

    public static void RestClientGet(WeakHashMap<String, Object> param, String url, ISuccess success, IError error, IFailure failure) {
        AtmosLogger.e("url", url);
        RestClient
                .builder()
                .token(FustionManager.mLoginData.getToken())
                .url(url)
                .params(param)
                .success(success)
                .failure(failure)
                .error(error)
                .build()
                .get();
    }

    public static void RestClientPostRaw(JSONObject json, String url, ISuccess success, IError error, IFailure failure) {
        AtmosLogger.e("url", url);
        RestClient
                .builder()
                .token(FustionManager.mLoginData.getToken())
                .url(url)
                .params(new WeakHashMap<String, Object>())
                .raw(json.toString())
                .success(success)
                .failure(failure)
                .error(error)
                .build()
                .post();
    }
}
